<meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <style type="text/css" rel="stylesheet">
    form {
    margin: 0;
    }
    .editor {
    margin-top: 5px;
    margin-bottom: 5px;
    }
    .ke-content {
    font-family: Courier New;
    font-size: 12px;
    background-color: #ffffff;}
  </style>
  <script type="text/javascript" charset="utf-8" src="/kindeditor/kindeditor.js"></script>
  <script type="text/javascript">
    
    KE.show({
        id : 'content_content',
        resizeMode :1,
        cssPath : '/kindeditor/examples/index.css',
        items : [
        'undo', 'redo', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
        'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
        'insertunorderedlist']
    });
  </script>
  <div id="operation">
     <a href="javascript:;" onclick="Element.hide('preview'); Element.hide('img_manage'); Element.show('updateDiv');">
     修改文章内容</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
     <a href="javascript:;" onclick="Element.hide('preview'); Element.hide('updateDiv'); Element.show('img_manage');">
     文章图片管理</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     
 </div>
  <!--显示-->
  <div id="preview">
            <div id="preview_left">
              <h3><%=  @content.title %></h3>
                 <ul>
                   <li>名称:<span><%=  @content.name %></span></li>
                   <li>标题:<span><%=  @content.title %></span></li>
                   <li>类型:<span><%= @content.c_type %></span></li>
                   <li>作者:<span><%= @content.author %></span></li>
                   <li>频道:<span><%= @content.channel_id %></span></li>
                   <li><p>内容:<span><%= @content.content%></span></li>
                 </ul>
             </div>
            <div id="preview_right">
               <!--图片展示-->
                 <% if @image == nil%>
                 暂无图片
                 <%else%>
                 <img src="<%='/upload/content_img/fullsize/'+@image.attributes['filename'] %>" width="190px" heigth="180"/>
                <% end %>
             </div>
  </div>
     <!--修改-->
   <div id="updateDiv" style="display:none" >
        <a href="javascript:;" onclick="Element.show('preview'); Element.hide('add_img'); Element.hide('updateDiv');">
       文章预览</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
         <% form_for(@content, :url => { :action => "update" }, :html => { :multipart => true }) do |f| %>
          <%= error_messages_for :content %>
          <h3>第 &nbsp;<%=@content.id%>&nbsp; 条内容</h3>
          <%= hidden_field_tag "content[id]", @content.id %><p>
          <div class="style02">名称:<%= f.text_field :name , :class=>"required" %></div>
          <div class="style01">标题:<%= f.text_field :title , :class=>"required"  %></div>
          <div class="style02">类型:<%= f.text_field :c_type , :class=>"required"  %></div>
          <div class="style01">作者:<%= f.text_field :author , :class=>"required" %></div>
          <div class="style01">频道:<select class="required"  name="content[channel_id]">
                  <% for ch in channel=Channel.find(:all) %>
                       <option value="<%=ch.id%>"><%=ch.name%></option>
                  <% end %>  
                  </select></div><p>
          <input type="hidden" name="content[is_article]" value="yes"/>
         <div class="style03">内容:<textarea  class="textarea_style" id="content_content" 
         name="content[content]" style="width:380px;height:210px;visibility;"><%= @content.content%>
          </textarea>
          </div>
         </p>
        <%= f.submit "修改" , :class=>"Button"%>
       </p>  
       <% end %>
  </div>
  <div id="img_manage" style="display:none">
  <br />
       &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" 
       onclick="Element.show('preview'); Element.hide('img_manage'); Element.hide('updateDiv');">
        文章预览</a> &nbsp;&nbsp;&nbsp;&nbsp;<br />
            <table class="datalist">
                  <tr>
                    <th scope="col" width="100px">名称</th>
                    <th scope="col" width="250px">图片</th>
                    <th scope="col" width="100px">是否使用</th>
                    <th colspan="3" scope="col" width="100px"></th>
                  </tr>
                    <% i = 0   
                    @images.each do |im| %>
                    <% if i%2 == 0 %>
                  <tr>  <% else %> <tr  class="altrow"> <% end %>
                    <td><%=h im.filename %></td>
                     <td>
                     <img src="<%='/upload/content_img/fullsize/'+im.attributes['filename'] %>" width="100px" heigth="120"/>
                     </td>
                     <td>
                      <% if im.using=="yes" -%>
                     使用中
                     <% elsif im.using =="no" -%>
                      停用中
                     <% else %>   
                      未指定 
                      <% end %>                 
                     </td>
                     <td><%= link_to '使用', {:id => im, :action => :image_using}  %></td>
                     <td><%= link_to '停用', {:id => im, :action => :image_stopusing}  %></td>
                    <td><%= link_to '删除', {:id => im, :action => :destroy_image}, :confirm => '确定删除?'  %></td>
                  </tr><%  i += 1  
                  end  %>
                </table>
                <br />
                <a href="javascript:;"onclick="Element.show('add_img');">
        增加图片</a> &nbsp;&nbsp;&nbsp;&nbsp;
        <!--添加图片-->
         <div id="add_img" style="display:none">
           <hr>
             <% form_for(:image, :url => {:action=>'create_image'}, :html => { :multipart => true }) do |f| -%> <p> 
               <label for="picture">增加图片:</label> 
             <%= f.file_field :uploaded_data %> 
               <input type ="hidden"  name ="c_id" value =<%=@content.id %> ></p> 
             <%= submit_tag '添加' , :class=>"Button" %> </p> 
          <% end -%>
       </div>
 </div>
